package Utils;

public class Utils {
	public static String Checksum(String nmeaSentence){
		int checksum = -1;
		String sInput= nmeaSentence; // e.g. "$PMTK313,1*" ==> checksum == 2E
		char[] c = sInput.toCharArray();
		for (int i = 0; i < c.length; i++) {
			if(c[i] == "$".toCharArray()[0]){}
			else if(c[i]=="*".toCharArray()[0]){break;}
			else{
				if(checksum == -1)
					checksum = c[i];
				else{
					checksum ^= c[i];
				}
			}
		}

		return Integer.toHexString(checksum).toUpperCase();
	}
	
//	public static <T extends Number> T ReverseDecode(int from, int to, String[] hexBytes, T answer) {
//		
//		for (int i = 0; i < hexBytes.length; i++) {
//			
//		}
//	}
}
